class Config {
    constructor() {
        this.configRequiredObjects = []
        this.data = {}
    }
    addConfigRequired(configRequiredObject) {
        this.configRequiredObjects.push(configRequiredObject);
    }
    init() {
        for (let x = 0;x<this.configRequiredObjects.length;x++) {
            console.log(x, this.configRequiredObjects);
            let cro = this.configRequiredObjects[x];
            cro.init(this.data);
        }
        this.data["yan_init"] = true;
    }
    store() {
        for (let x = 0;x<this.configRequiredObjects.length;x++) {
            let cro = this.configRequiredObjects[x];
            console.log(cro);
            cro.store(this.data);
        }
        for (let key in self.data) {
            localStorage[key] = self.data[key];
        }
    }
    config() {
        for (let x = 0;x<this.configRequiredObjects.length;x++) {
            let cro = this.configRequiredObjects[x];
            cro.config(this.data);
        }
    }
    getConfig() {       
        // name 不存在就创建, 并初始化
        this.data = localStorage;
        if (!this.data["yan_init"]) {
            this.init()
        }
        // 读取所需
        this.config()
    }   
}

export {
    Config
}